package sort_code;

//选择排序，从0索引开始依次与后面的数做比较
public class Selection {
    public static void main(String[] args) {
        int[] arr = {4,7,1,2,9,3,10,5,8,6};

        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i+1; j < arr.length; j++) {
                if(arr[i] > arr[j]){
                    int tmp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = tmp;
                }
            }
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
